 
 
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>镜像站@layer弹出层 - 在线演示 - Layui</title>
<meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="apple-mobile-web-app-status-bar-style" content="black"> 
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="format-detection" content="telephone=no">
  <script>
  ;!function(){self!==parent&&(location.href="http://www.baidu.com/")}();
  </script>
  <link rel="stylesheet" href="../../res.layui.com/layui/dist/css/layui.css" tppabs="http://res.layui.com/layui/dist/css/layui.css?t=1632428048355"  media="all">
  <link rel="stylesheet" href="../../res.layui.com/static/css/global.css" tppabs="http://res.layui.com/static/css/global.css?t=1632428048355-19" media="all">
</head>
<body>
<div class="layui-layout layui-layout-admin">
  

<div class="layui-header header header-demo" autumn>
  <div class="layui-fluid">
    <a class="logo" href="../index.htm" tppabs="http://www.layui.com/">
      <img src="../../res.layui.com/static/images/layui/logo.png" tppabs="http://res.layui.com/static/images/layui/logo.png" alt="layui">
    </a>
    <div class="layui-form layui-hide-xs component" lay-filter="LAY-site-header-component"></div>
    <div class="layui-hide-xs site-notice"></div>
    
    <ul class="layui-nav" id="LAY_NAV_TOP">
      <li class="layui-nav-item ">
        <a href="../doc/index.htm" tppabs="http://www.layui.com/doc/">文档</a> 
      </li>
      <li class="layui-nav-item layui-this">
        <a href="index.htm" tppabs="http://www.layui.com/demo/">示例</a>
      </li>
      
      <li class="layui-nav-item">
        <a href="javascript:;">
          <!--<span class="layui-badge-dot" style="left:0; right: auto; margin: -4px 0 0 5px;"></span>--> 
          周边
        </a>
        <dl class="layui-nav-child layui-nav-child-c">  
          <dd class="layui-hide-sm layui-show-xs" lay-unselect>
            <a href="https://gitee.com/sentsin/layui/issues" target="_blank" rel="nofollow">问题反馈</a>
            <hr>
          </dd>
          
          <dd lay-unselect><a href="../alone.html" tppabs="http://www.layui.com/alone.html" target="_blank" lay-unselect>独立组件</a></dd>
          <dd lay-unselect><a href="../../fly.layui.com/extend/index.htm" target="_blank">扩展组件</a></dd>
        </dl>
      </li>
      
      <li class="layui-nav-item layui-hide-xs">
        <a href="http://gitee.com/sentsin/layui/issues" target="_blank" rel="nofollow">反馈</a>
      </li>
    </ul>
  </div>
</div>
 
<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
<!--[if lt IE 9]>
  <script src="../../other/html5shiv/r29/html5.min.js" tppabs="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  <script src="../../other/respond.js/1.4.2/respond.min.js" tppabs="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
 
  <div class="layui-side layui-bg-black">
    <div class="layui-side-scroll">
      
<ul class="layui-nav layui-nav-tree site-demo-nav">
  
  <li class="layui-nav-item layui-nav-itemed">
    <a class="javascript:;" href="javascript:;">演示</a>
    <dl class="layui-nav-child">
      <dd>
        <a href="index.htm" tppabs="http://www.layui.com/demo/">调试预览</a>
      </dd>
    </dl>
  </li>
  
  <li class="layui-nav-item layui-nav-itemed">
    <a class="javascript:;" href="javascript:;">布局</a>
    <dl class="layui-nav-child">
      <dd class="">
        <a href="grid.html" tppabs="http://www.layui.com/demo/grid.html">栅格</a>
      </dd>
      <dd class="">
        <a href="admin.html" tppabs="http://www.layui.com/demo/admin.html">框架</a>
      </dd>
    </dl>
  </li>
  
  <li class="layui-nav-item layui-nav-itemed">
    <a class="javascript:;" href="javascript:;">基本元素</a>
    <dl class="layui-nav-child">
      <dd class="">
        <a href="button.html" tppabs="http://www.layui.com/demo/button.html">按钮</a>
      </dd>
      <dd class="">
        <a href="form.html" tppabs="http://www.layui.com/demo/form.html">表单</a>
      </dd>
      <dd class="">
        <a href="nav.html" tppabs="http://www.layui.com/demo/nav.html">导航 / 面包屑</a>
      </dd>
      <dd class="">
        <a href="menu.html" tppabs="http://www.layui.com/demo/menu.html">基础菜单</a>
      </dd>
      <dd class="">
        <a href="tab.html" tppabs="http://www.layui.com/demo/tab.html">选项卡</a>
      </dd>
      <dd class="">
        <a href="progress.html" tppabs="http://www.layui.com/demo/progress.html">进度条</a>
      </dd>
      <dd class="">
        <a href="panel.html" tppabs="http://www.layui.com/demo/panel.html">面板</a>
      </dd>
      <dd class="">
        <a href="badge.html" tppabs="http://www.layui.com/demo/badge.html">徽章</a>
      </dd>
      <dd class="">
        <a href="timeline.html" tppabs="http://www.layui.com/demo/timeline.html">时间线</a>
      </dd>
      <dd class="">
        <a href="table-element.html" tppabs="http://www.layui.com/demo/table-element.html">静态表格</a>
      </dd>
      <dd class="">
        <a href="anim.html" tppabs="http://www.layui.com/demo/anim.html">动画</a>
      </dd>
      <dd class="">
        <a href="auxiliar.html" tppabs="http://www.layui.com/demo/auxiliar.html">辅助元素</a>
      </dd>
    </dl>
  </li>
  
  <li class="layui-nav-item layui-nav-itemed">
    <a class="javascript:;" href="javascript:;">组件示例</a>
    <dl class="layui-nav-child">
      <dd class="layui-this">
        <a href="layer.html" tppabs="http://www.layui.com/demo/layer.html">
          弹出层
        </a>
      </dd>
      <dd class="">
        <a href="laydate.html" tppabs="http://www.layui.com/demo/laydate.html">
          日期与时间选择
        </a>
      </dd>
      <dd class="">
        <a href="table.html" tppabs="http://www.layui.com/demo/table.html">
          数据表格
        </a>
      </dd>
       <dd class="">
        <a href="laypage.html" tppabs="http://www.layui.com/demo/laypage.html">
          分页
        </a>
      </dd>
      <dd class="">
        <a href="dropdown.html" tppabs="http://www.layui.com/demo/dropdown.html">
          下拉菜单
        </a>
      </dd>
      <dd class="">
        <a href="upload.html" tppabs="http://www.layui.com/demo/upload.html">
          文件上传
        </a>
      </dd>  
      <dd class="">
        <a href="transfer.html" tppabs="http://www.layui.com/demo/transfer.html">
          穿梭框
        </a>
      </dd>
      
       <dd class="">
        <a href="tree.html" tppabs="http://www.layui.com/demo/tree.html">
          树形组件
        </a>
      </dd>
      <dd class="">
        <a href="colorpicker.html" tppabs="http://www.layui.com/demo/colorpicker.html">
          颜色选择器
        </a>
      </dd>
      <dd class="">
        <a href="slider.html" tppabs="http://www.layui.com/demo/slider.html">
          滑块
        </a>
      </dd>
      <dd class="">
        <a href="rate.html" tppabs="http://www.layui.com/demo/rate.html">
          评分
        </a>
      </dd>
      <dd class="">
        <a href="carousel.html" tppabs="http://www.layui.com/demo/carousel.html">
          轮播
        </a>
      </dd>
      <dd class="">
        <a href="laytpl.html" tppabs="http://www.layui.com/demo/laytpl.html">
          模板引擎
        </a>
      </dd>
      <dd class="">
        <a href="flow.html" tppabs="http://www.layui.com/demo/flow.html">
          流加载
        </a>
      </dd>
      <dd class="">
        <a href="util.html" tppabs="http://www.layui.com/demo/util.html">
          工具模块
        </a>
      </dd>
      <dd class="">
        <a href="code.html" tppabs="http://www.layui.com/demo/code.html">
          文本行修饰
        </a>
      </dd>
    </dl>
  </li>
  
  <li class="layui-nav-item" style="height: 30px; text-align: center"></li>
</ul>

    </div>
  </div>
  <div class="layui-tab layui-tab-brief" lay-filter="demoTitle">
    <ul class="layui-tab-title site-demo-title">
      <li class="layui-this">预览</li>
      <li>查看代码</li>
      <li>帮助</li>
    </ul>
    <div class="layui-body layui-tab-content site-demo site-demo-body">
    
    
      <div class="layui-tab-item layui-show">
        <div class="layui-main">
          <div id="LAY_preview">
          
<blockquote class="layui-elem-quote">
  大部分演示都在 layer 独立组件的官网（<a class="layui-font-blue" href="https://layer.layui.com/" target="_blank">layer.layui.com</a>），与内置的 layer 模块，用法是完全一致的
</blockquote>
 
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  <legend>特殊例子</legend>
</fieldset>
 
<div id="layerDemo" style="margin-bottom: 0;">
  <blockquote class="layui-elem-quote layui-quote-nm">
    Tips：为了更清晰演示，每触发下述一个例子之前，都会关闭所有已经演示的层
  </blockquote>
  
  <div class="layui-btn-container" style="margin-top: 30px;">
    <button data-method="setTop" class="layui-btn">多窗口模式 + 层叠置顶 + Esc 关闭</button>
    <button data-method="confirmTrans" class="layui-btn">配置一个透明的询问框</button>
    <button data-method="notice" class="layui-btn">示范一个公告层</button>
  </div>
  <div class="layui-btn-container">
    <button data-method="offset" data-type="t" class="layui-btn layui-btn-normal">上弹出</button>
    <button data-method="offset" data-type="r" class="layui-btn layui-btn-normal">右弹出</button>
    <button data-method="offset" data-type="b" class="layui-btn layui-btn-normal">下弹出</button>
    <button data-method="offset" data-type="l" class="layui-btn layui-btn-normal">左弹出</button>
    <button data-method="offset" data-type="lt" class="layui-btn layui-btn-normal">左上弹出</button>
    <button data-method="offset" data-type="lb" class="layui-btn layui-btn-normal">左下弹出</button>
    <button data-method="offset" data-type="rt" class="layui-btn layui-btn-normal">右上弹出</button>
    <button data-method="offset" data-type="rb" class="layui-btn layui-btn-normal">右下弹出</button>
    <button data-method="offset" data-type="auto" class="layui-btn layui-btn-normal">居中弹出</button>
  </div>
  
  <div style="margin-top: 15px">
     
<!-- 示例-970 -->

  
  </div>
</div>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
  <legend>更多示例</legend>
</fieldset>
<a class="layui-btn layui-btn-normal" href="https://layer.layui.com/" target="_blank">去 layer 官网查看</a>
   
          </div>
        </div>
      </div>
      
      
      <div class="layui-tab-item">
<textarea class="layui-border-box site-demo-text site-demo-code" id="LAY_democode" spellcheck="false" readonly>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>镜像站@Layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../../res.layui.com/layui/dist/css/layui.css" tppabs="http://res.layui.com/layui/dist/css/layui.css"  media="all">
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
</textarea>
      </div>
      
      
      <div class="layui-tab-item">
        <div class="layui-main">
          <p></p>
          
          
          
          <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
            <legend>相关</legend>
          </fieldset>
          <a class="layui-btn layui-btn-normal" href="../doc/modules/layer.html" tppabs="http://www.layui.com/doc/modules/layer.html" target="_blank">layer文档</a>
        </div>
      </div>
      
        
    </div>
  </div>
  
<div class="layui-footer footer footer-demo">
    <p>
      Copyright &copy; 2021 <a href="../index.htm" tppabs="http://www.layui.com/">layui.com</a> MIT Licensed</p>
    <p>
      <a href="../about/disclaimer.html" tppabs="http://www.layui.com/about/disclaimer.html" target="_blank">免责声明</a> 
      <a href="../about/relatedlinks.html" tppabs="http://www.layui.com/about/relatedlinks.html" target="_blank">友链</a>
      <a href="javascript:;"  site-event="weixinmp">公众号</a>
      <a target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=36010902000274"  rel="nofollow">
        <img src="../../res.layui.com/upload/2021_8/168_1628847893037_87773.png" tppabs="http://cdn.layui.com/upload/2021_8/168_1628847893037_87773.png">
        公网安备 00000000000000号
      </a>
      <a href="https://beian.miit.gov.cn/" target="_blank" rel="nofollow">ICP备00000000号</a>
    </p>
    <div class="site-union">
      <p class="site-union-desc">
        <span>
          
        </span>
      </p>

    </div>
</div>
<script>
window.global = {
  pageType: 'demo'
  ,preview: function(){
    var preview = document.getElementById('LAY_preview');
    return preview ? preview.innerHTML : '';
  }()
};
</script>

<div class="site-tree-mobile layui-hide">
  <i class="layui-icon layui-icon-spread-left"></i>
</div>
<div class="site-mobile-shade"></div>
 
<script src="../../res.layui.com/layui/dist/layui.js" tppabs="http://res.layui.com/layui/dist/layui.js?t=1632428048355" charset="utf-8"></script>
<script>
layui.config({
  base: '../../res.layui.com/static/lay/modules/layui/'
  ,version: '1632428048355'
}).use('global');
</script>
 


</div>
<div id="LAY_democodejs">
<script>
layui.use('layer', function(){ //独立版的layer无需执行这一句
  var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
  
  //触发事件
  var active = {
    setTop: function(){
      var that = this; 
      //多窗口模式，层叠置顶
      layer.open({
        type: 1 //此处以iframe举例
        ,title: '当你选择该窗体时，即会在最顶端'
        ,area: ['390px', '260px']
        ,shade: 0
        ,maxmin: true
        ,offset: [ //为了演示，随机坐标
          Math.random()*($(window).height()-300)
          ,Math.random()*($(window).width()-390)
        ] 
        ,content: '<div style="padding: 15px;">内容标记：'+ new Date().getTime() + '，按 ESC 键可关闭。<br><br>当你的页面有很多很多 layer 窗口，你需要像 Window 窗体那样，点击某个窗口，该窗体就置顶在上面，那么 layer.setTop() 可以来轻松实现。它采用巧妙的逻辑，以使这种置顶的性能达到最优。</div>'
        
        ,btn: ['继续弹出', '全部关闭'] //只是为了演示
        ,yes: function(){
          $(that).click(); 
        }
        ,btn2: function(){
          layer.closeAll();
        }
        
        ,zIndex: layer.zIndex //重点1
        ,success: function(layero, index){
          layer.setTop(layero); //重点2. 保持选中窗口置顶
          
          //记录索引，以便按 esc 键关闭。事件见代码最末尾处。
          layer.escIndex = layer.escIndex || [];
          layer.escIndex.unshift(index);
          //选中当前层时，将当前层索引放置在首位
          layero.on('mousedown', function(){
            var _index = layer.escIndex.indexOf(index);
            if(_index !== -1){
              layer.escIndex.splice(_index, 1); //删除原有索引
            }
            layer.escIndex.unshift(index); //将索引插入到数组首位
          });
        }
        ,end: function(){
          //更新索引
          if(typeof layer.escIndex === 'object'){
            layer.escIndex.splice(0, 1);
          }
        }
      });
    }
    ,confirmTrans: function(){
      //配置一个透明的询问框
      layer.msg('大部分参数都是可以公用的<br>合理搭配，展示不一样的风格', {
        time: 20000, //20s后自动关闭
        btn: ['明白了', '知道了', '哦']
      });
    }
    ,notice: function(){
      //示范一个公告层
      layer.open({
        type: 1
        ,title: false //不显示标题栏
        ,closeBtn: false
        ,area: '300px;'
        ,shade: 0.8
        ,id: 'LAY_layuipro' //设定一个id，防止重复弹出
        ,btn: ['火速围观', '残忍拒绝']
        ,btnAlign: 'c'
        ,moveType: 1 //拖拽模式，0或者1
        ,content: '<div style="padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;">你知道吗？亲！<br>layer ≠ layui<br><br> layer 只是作为 layui 的一个弹层模块，由于其用户基数较大，所以常常会有人以为 layui 是 <del>layerui</del><br><br>layer 虽然已被 Layui 收编为内置的弹层模块，但仍然会作为一个独立组件全力维护、升级 ^_^</div>'
        ,success: function(layero){
          var btn = layero.find('.layui-layer-btn');
          btn.find('.layui-layer-btn0').attr({
            href: '../index.htm'/*tpa=http://www.layui.com/*/
            ,target: '_blank'
          });
        }
      });
    }
    ,offset: function(othis){
      var type = othis.data('type')
      ,text = othis.text();
      
      layer.open({
        type: 1
        ,offset: type //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
        ,id: 'layerDemo'+type //防止重复弹出
        ,content: '<div style="padding: 20px 100px;">'+ text +'</div>'
        ,btn: '关闭全部'
        ,btnAlign: 'c' //按钮居中
        ,shade: 0 //不显示遮罩
        ,yes: function(){
          layer.closeAll();
        }
      });
    }
  };
  
  $('#layerDemo .layui-btn').on('click', function(){
    var othis = $(this), method = othis.data('method');
    active[method] ? active[method].call(this, othis) : '';
  });
  
  
  //多窗口模式 - esc 键
  $(document).on('keyup', function(e){
    if(e.keyCode === 27){
      layer.close(layer.escIndex ? layer.escIndex[0] : 0);
    }
  });
});
</script>
</div>
</body>
</html>